#ifndef DLL_LINKED_LIST_H
#define DLL_LINKED_LIST_H

#include "bbAddon.h"

using namespace std;

static int _Debug_COUNTLINKS	= 0;

/* Double Linked-List */
class TLink;
		
class TList{
public :
	TList();
	~TList();
	TLink* _head;
	TLink* _tail;
};

class TLink{
public :
	TLink();
	~TLink();
	TList* _list;
	string _data;
	TLink* _next;
	TLink* _prev;

	friend TLink* NullLink();
};

static TLink* _NULL_LINK = new TLink();

inline void Unlink(TLink* lnk);

BBAEXP void BBACALL DeleteList (TList * list);
BBAEXP void BBACALL DeleteLink (TLink * lnk);
BBAEXP void BBACALL SetLinkValue (TLink* lnk, const char* datas);
BBAEXP int BBACALL NewList();
BBAEXP int BBACALL ListInsertAfter(TLink* lnk, TLink* after);
BBAEXP int BBACALL ListInsertBefore(TLink* lnk, TLink* before);
BBAEXP int BBACALL ListAddLast(TList* list, const char* pValue);
BBAEXP int BBACALL ListAddFirst(TList* list, const char* pValue);
BBAEXP int BBACALL ListContains(TList* list, const char* value);
BBAEXP const int BBACALL ListIsEmpty(const TList* list);
BBAEXP const int BBACALL FirstLink(const TList* list);
BBAEXP const int BBACALL LastLink(const TList* list);
BBAEXP const int BBACALL AfterLink(const TLink* link);
BBAEXP const int BBACALL BeforeLink(const TLink* link);
BBAEXP int BBACALL len(const char* a);
BBAEXP int BBACALL LinkCompare(const TLink* l1, const TLink* l2);
BBAEXP int BBACALL StrCompare(const char* a, const char* b);
BBAEXP const char* BBACALL LinkValue(const TLink* link);
BBAEXP int BBACALL SwapLinks(TLink* l1, TLink* l2);
BBAEXP int BBACALL SortList(TList* list, int sens);


#endif //DLL_LINKED_LIST_H